package 数据结构下

object ScanDemo01 {
  def main(args: Array[String]): Unit = {

    def minus(n1: Int, n2: Int): Int = {
      n1 - n2
    }

    /**
     * 和fold 折叠的区别: scan会保留初始值并加入返回的indexSqe[Int]中
     */
    val value = (1 to 5).scanLeft(5)(minus)
    println(value)
  }

}
